<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Universum.Views.Resource.ResourceViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Universum - Manage your resources
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<h2>
		Manage your resources</h2>
	<div class="span-24">
		<table class="span-5">
			<tr>
				<td>
					<%= Html.ActionLink<Universum.Controllers.ResourceController>( go=>go.CreateFile(Model.UserPath),"Upload file") %>
					|
				</td>
				<td>
					<% if (Model.IsInsideFolder)
		{%>
					<%= Html.ActionLink<Universum.Controllers.ResourceController>(go => go.CreateFolder(), "New folder")%>
					<% }
		else
		{
					%>
					<%Html.BeginForm<ResourceController>(forAction => forAction.DeleteFolder(Model.UserPath)); %>
					<%=Html.SubmitButton("DeleteFolder", "Delete folder")%>
					<% Html.EndForm();
	 }
					%>
				</td>
			</tr>
		</table>
	</div>
	<div class="span-24">
		<div class="span-24">
			<%if (Model.IsInsideFolder.IsFalse())
	 { %>
			<a href="<%= Html.BuildUrlFromExpression<ResourceController>(fromAction=>fromAction.Index("")) %>">
				<img alt="Back to index" src="<%= new ContentDirectoryService("/images/back_to_index_ikon.png").Path %>" /></a>
			<%} %>
		</div>
		<% foreach (var directory in Model.Directories)
	 {
		%>
		<div class="span-2">
			<center>
				<%Html.BeginLink<ResourceController>(callTo => callTo.Index(directory)); %>
				<img alt="<%=directory %>" src="<%= new ContentDirectoryService("/images/folder_ikon.png").Path %>" />
				<%--<%= Html.UserActionLink<ResourceController>(callTo=>callTo.Browse(directory),directory)%>--%>
				<br />
				<span><%=directory %></span>
				<%Html.EndLink(); %>
			</center>
		</div>
		<% } %>
		<hr class="span-16" />
		<% foreach (var key in Model.FileTypes.Keys)
	 {
		 foreach (var value in Model.FileTypes[key])
		 {
		%>
		<div class="span-4 limit-image">
			<center>
				<table class="span-2">
					<tr>
					<% if (value.IsContentPresentationPossible){ %>
						<td>
							<% Html.BeginLink<ResourceController>(callFor=> callFor.ShowFile(value.Id)); %>
							<img title="View content" src="<%= new ContentDirectoryService("images/details.png").Path %>" />
							<% Html.EndLink(); %>
						</td>
					<%} %>
					<td>
						<% Html.BeginLink<ResourceController>(callFor=> callFor.Details(value.Id)); %>
						<img title="Resource link" src="<%= new ContentDirectoryService("images/resource-link.png").Path %>" />
						<% Html.EndLink(); %>
					</td>
						<td>
							<% Html.BeginForm<ResourceController>(callFor => callFor.DownloadFile(value.Id), FormMethod.Post);
							%>
							<input class="download-content" title="Download content" type="image" src="<%= new ContentDirectoryService("images/download.png").Path %>" />
							<%Html.EndForm(); %>
						</td>
						<td>
							<%Html.BeginForm<ResourceController>(callFor => callFor.DeleteFile(Model.UserPath, value.Id), FormMethod.Post); %>
							<input title="Remove content" type="image" src="<%= new ContentDirectoryService("images/delete.png").Path %>" />
							<% Html.EndForm(); %>
					</tr>
				</table>
				<% if (value.IsImage)
	   { %>
				<img alt="<%=value %>" width="48px" height="48px" src="<%= Html.RouteUrl<ResourceController>(to=>to.ShowFile(value.Id)) %>" />
				<%} else { %>
				<img alt="<%=value %>" width="48px" height="48px" src="<%= new ContentTypeRepresentationService(key).Path %>" />
				<% } %>
				<br />
				<span style="overflow:hidden" >
					<%=value.FileName %></span>
			</center>
		</div>
		<% 
			}
	 } %>
	</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ScriptPlaceHolder" runat="server">
<link type="text/css" rel="Stylesheet" href="<%=Html.ResolveUrl("~/content/css/jquery.tooltip.css") %>" />
<script language="javascript" type="text/javascript" src="<%=Html.ResolveUrl("~/content/scripts/jquery.dimensions.js") %>"></script>
	<script language="javascript" type="text/javascript" src="<%=Html.ResolveUrl("~/content/scripts/jquery.tooltip.min.js") %>"></script>
	<script language="javascript" type="text/javascript">
		$(function() {
			$("img").tooltip({ showURL: false });
			
			$("input:image").tooltip({
				showURL: false

			});


		});
	</script>
	
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Breadcrumbs" runat="server">
<%= Html.Breadcrumb().Home().AppendText("Resources").End() %>
</asp:Content>
